package com.eckey.lab.config;

import javax.servlet.http.HttpServletRequest;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * @Author: Marinc
 * @CreateTime: 2023-08-09  22:01
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@Component
public class RequestParse implements RequestOriginParser {

    public String parseOrigin(HttpServletRequest httpServletRequest) {
        String origin = httpServletRequest.getHeader("origin");
        if (StringUtils.isEmpty(origin) || !origin.equals("gateway")) {
            origin = "blank";
        }
        log.info("origin:{}", origin);
        return origin;
    }
}
